#region Imported Namespaces


using System.Collections.ObjectModel;


#endregion


namespace WtfManager.HierarchicalData
{
  ///<summary>
  /// Represents a read-only <see cref="TreeItem"/> collection.
  ///</summary>
  public class ReadOnlyTreeItemsCollection: ReadOnlyObservableCollection<TreeItem>
  {
    #region Fields


    private readonly TreeItemsCollection _collection;


    #endregion


    #region Constructors/Finalizers


    ///<summary>
    /// Default ReadOnlyTreeItemsCollection constructor.
    ///</summary>
    public ReadOnlyTreeItemsCollection(TreeItemsCollection collection)
      : base(collection)
    {
      _collection = collection;
    }


    #endregion


    #region Properties/Indexers


    ///<summary>
    /// Gets a <see cref="TreeItem"/> by name.
    ///</summary>
    ///<param name="name">A name of <see cref="TreeItem"/> to get.</param>
    public TreeItem this[string name]
    {
      get
      {
        return _collection[name];
      }
    }


    #endregion


    #region Methods


    public bool Contains(string name)
    {
      foreach (TreeItem item in this)
      {
        if (item.Name == name)
        {
          return true;
        }
      }

      return false;
    }


    #endregion
  }
}